<?php

namespace common\models\business;

use Yii;

/**
 * This is the model class for table "business_pig_price_type".
 *
 * @property string $id
 * @property string $name
 * @property string $unit
 * @property string $remark
 * @property integer $createtime
 */
class BusinessPigPriceType extends \yii\db\ActiveRecord
{

       //主要用于日志记录
    public $uselog = [
        'tabcomment' => '分类类型',      //用于修改了什么的显示
        'mainfield' => 'name',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];



    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'business_pig_price_type';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name','unit'],'required'],
            [['createtime'], 'integer'],
            [['name'], 'string', 'max' => 11],
            [['unit'], 'string', 'max' => 10],
            [['remark'], 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '分割类型名称',
            'unit' => '销售单位',
            'remark' => '备注',
            'createtime' => '创建时间',
        ];
    }

    public function beforeSave($insert)
    {
        if($this->isNewRecord){
            $this->createtime = time();
        }
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }
}
